import axios from 'axios'

// 修改list
export const SET_LIST = 'SET_LIST'
// 添加到购物车
export const ADD_CART = 'ADD_CART'

// 修改商品数量
export const CHANGE_COUNT = 'CHANGE_COUNT'
//改变选择框
export const CHANGE_FLAG = 'CHANGE_FLAG'
//全选
export const ALL_CHECK = 'ALL_CHECK'


export function getList(dispatch){
    axios.get('/list').then(res => {
        dispatch({type: SET_LIST, list: res.data})
    })
}


export function addCart(info){
    return { type: ADD_CART, info }
}

export function changeCount(id, count){
    return { type: CHANGE_COUNT, id, count }
}
export function changeflag(value, id){
    return { type: CHANGE_COUNT, value, id }
}
export function allCheck(value){
    return {type:ALL_CHECK , value}
}